//
//  XZMemberListCell.m
//  Teecloud
//
//  Created by PC on 2018/11/5.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "XZMemberListCell.h"

@interface XZMemberListCell ()
//图片
@property (weak, nonatomic) IBOutlet UIImageView *headImg;
//信息
@property (weak, nonatomic) IBOutlet UILabel *msgLabel;
//name TeacherInfo
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
//RoleName
@property (weak, nonatomic) IBOutlet UILabel *rolenameLabel;
//考核
@property (weak, nonatomic) IBOutlet UIButton *assessButton;
//RoleName的宽
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rolenameWidth;
//承装考核跟电话的view的宽度
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rightViewWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *nameTop;

@end
//培训中
#define KTrainColor [UIColor colorWithHexString:@"#FF9900" andAlpha:1.0]
@implementation XZMemberListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.rolenameLabel.layer.cornerRadius = 3.0f;
    self.rolenameLabel.clipsToBounds = YES;
    self.rolenameLabel.layer.borderWidth = 1.0f;
    self.rolenameLabel.layer.borderColor =KTrainColor.CGColor;
}
- (void)setModel:(XZMemberData *)model{
    _model = model;
    [self.headImg yy_setImageWithURL:[NSURL URLWithString:model.HeadUrl] placeholder:[UIImage imageNamed:@"People"]];
    self.msgLabel.text = model.LastMsg;
    if (!kIsEmptyString(model.LastMsg)) {
        self.nameTop.constant = 0;
    }else{
        self.nameTop.constant = 14.f;
    }
    if (model.TeacherInfo.length > 0) {
        self.nameLabel.text = [NSString stringWithFormat:@"%@%@",model.Name,model.TeacherInfo];
    }else{
        self.nameLabel.text = model.Name;
    }
    
    if (model.RoleName.length > 0) {
        self.rolenameLabel.hidden = false;
        self.rolenameLabel.text = model.RoleName;
        CGSize roleNameWidth = [model.RoleName boundingRectWithSize:CGSizeMake(MAXFLOAT, 11.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.rolenameLabel.font} context:nil].size;
        self.rolenameWidth.constant = roleNameWidth.width+6;
    }else{
        self.rolenameLabel.hidden = true;
    }
    

}
//配置 (社团小组详情中的GroupConfig数据)
- (void)setGroupConfig:(XZGroupConfig *)groupConfig{
    _groupConfig = groupConfig;
    NSString *userId = [XGMArchiverTools cacheForKey:USER_UserId];
    if (groupConfig.IsManageRole && groupConfig.CheckTypeNames.count > 0 && ![userId isEqualToString:self.model.UserId]) {//显示
        self.assessButton.hidden = false;
         self.rightViewWidth.constant = 67;
    }else{//隐藏
        self.assessButton.hidden = true;
        self.rightViewWidth.constant = 34;
    }
}
//考核
- (IBAction)assessButtonAction:(UIButton *)sender {
    if (self.MemberContentBlock) {
        self.MemberContentBlock(self.model);
    }
}
//打电话
- (IBAction)takePhoneAction:(UIButton *)sender {
    if (self.takePhoneBlock) {
        self.takePhoneBlock(self.model);
    }
}

@end
